home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group98b.txt / 000065_icon-group-sender _Thu Jun 4 08:05:51 1998.msg < prev    next >
Internet Message Format  |  2000-09-20  |  6KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.8/8.8.7) with SMTP id IAA20190
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Thu, 4 Jun 1998 08:05:50 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA11122; Thu, 4 Jun 1998 08:05:42 -0700
  7. Date: Thu, 4 Jun 1998 14:20:21 +1200 (NZST)
  8. From: "Richard A. O'Keefe" <ok@atlas.otago.ac.nz>
  9. Message-Id: <199806040220.OAA29849@atlas.otago.ac.nz>
  10. To: icon-group@optima.CS.Arizona.EDU, nevin@pendragon-software.com
  11. Subject: Re: Directory access facilities
  12. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  13. Status: RO
  14. Content-Length: 5259
  15.  
  16. In reponse to messages like 
  17.  
  18.     >I'd prefer a simple built-in function that would generate the names
  19.     >of the files contained in a directory, e.g.
  20.     > contents(s)
  21.     >with other mechanisms (if any) used for finding attributes.
  22.     
  23. and
  24.  
  25.     I agree with you here, Gregg.  Probably need to, as a minimum, add a second
  26.     function to determine if a given string refers to a directory name.
  27.     Something like:
  28.     
  29. I'd like to say that people seem to have missed the point of my reference
  30. to Tcl/Tk.  The point is that there is an *existing* *multiplatform*
  31. implementation of this idea that *works*.  We don't have to design.
  32. We can steal.
  33.  
  34. The *last* thing we have any shadow of an excuse for doing is bodging
  35. together yet another incompatible design by appealing to "preferences".
  36.  
  37. Of course Tcl/Tk isn't the only thing around that one might reasonably
  38. copy.  There's the POSIX 'glob' function, for example, which is given
  39. a pathname with wilcards and some options, and returns an array of
  40. strings (in which any character whatsoever except \0 may occur).  One
  41. could have a very nice interface _based_ on glob(3c) + stat(2); any
  42. platform offering FindFirst/FindNext can emulate glob() easily enough.
  43.  
  44. Nevin Liber wrote:
  45.  
  46.     I would also vote against filtering out "." and ".."; dir() should return an
  47.     accurate representation of what is in the directory, and not require any
  48.     special casing (and it is trivial to filter this out at a higher level).
  49.  
  50. But where did you get the idea that the presence of "." and ".." was 'an
  51. accurate representation of what is in the directory'?  There are POSIX
  52. implementations that go to some trouble to fake these entries because the
  53. _real_ directory format _doesn't_ have them.  Do you want to filter them
  54. out when you know they've been faked and include them when you know they
  55. haven't?  It's better if they are _always_ present or _always_ absent
  56. whatever is really on the disc.  Note that the POSIX.1 standard (ok, so I
  57. have an old copy) says very clearly and explicitly
  58.  
  59.     5.1.2.2
  60.     43  The readdir() function shall not return directory entries
  61.         containing empty names.
  62. ===>    44  It is unspecified whether entries are returned for
  63.         dot or dot-dot.
  64.  
  65.     B5.1.2
  66.     2956 The directory entries for dot and dot-dot are optional.
  67.          POSIX does not provide a
  68.     2957 way to test a priori for their existence because
  69.          an application that is portable
  70.     2958 must be written to look for (and usually ignore)
  71.          those entries.
  72.  
  73. There really are "POSIX" systems where those things AREN'T on the disk.
  74. And of course there are non-POSIX systems that don't use "." or ".."
  75. for anything particular.  Indeed, there's one file system I retain
  76. considerable fondness for where the directory namespace and the file
  77. namespace are disjoint, so that the same name _can_ be used for a directory
  78. and a file at the same time, and often is.  E.g.
  79.     (MAT212X)THESIS/PLOTTER/SOURCE ON USERPACK    => Algol source form
  80.     (MAT212X)THESIS/PLOTTER ON USERPACK         => executable code
  81. where .../PLOTTER is a file name and .../PLOTTER/ is a directory name.
  82. To the best of my knowledge there isn't any Icon implementation for that
  83. machine, but there's a standard C compiler and a near-enough-to-POSIX
  84. OS interface, so there _could_ be an Icon implementation.
  85.  
  86. This _does_ count as a criticism of 'imitate Tcl/Tk' and 'imitate POSIX'
  87. because it strongly suggests that separate functions for finding
  88. directories and finding files would be appropriate.  (That's the way I
  89. did it for Quintus Prolog, with
  90.     file_member_of_directory(Directory[, Pattern], File)
  91.     directory_member_of_directory(Directory[, Pattern], SubDir)
  92.     file_property(File, Property, Value)
  93.     directory_property(Directory, Property, Value)
  94. operations.  Mind you, that had to be portable across MacOS, MS-DOS,
  95. Unix, VMS, VM/CMS, MVS, and Xerox Lisp (XNS) so it was a bit more
  96. portable than Icon may need to be.)  As I've hinted above, we could
  97. patch around this particular problem by insisting that directory names
  98. always end with a (native) separator and file names not; this will work
  99. straight out of the box on many UNIX systems where dirname/ is equivalent
  100. to dirname/., but can reasonably be faked anywhere, so a single interface
  101. will do.
  102.  
  103. One particular point about citing Tcl/Tk is the file license.terms in
  104. the Tcl8.0 distribution, which says amongst other things
  105.  
  106.     The authors hereby grant permission to use, copy, modify,
  107.     distribute, and license this software and its documentation
  108.     for any purpose, provided that existing copyright notices
  109.     are retained in all copies and that this notice is included
  110.     verbatim in any distributions.  No written agreement, license,
  111.     or royalty fee is required for any of the authorized uses.
  112.     Modifications to this software may be copyrighted by their
  113.     authors and need not follow the licensing terms described
  114.     here, provided that the new terms are clearly indicated on
  115.     the first pagev of each file where they apply.
  116.  
  117. What this means is that if the Icon interface is based on the Tcl/Tk
  118. interface, two important benefits follows:
  119.  
  120.     - a multiplatform interface which is *known* to be usable will
  121.       be available for very little design effort
  122.     - a multiplatform *tested* implementation will be available *free*.
  123.  
  124. I must ask:  why reinvent what we can steal?
  125.  
  126.